package com.demboos.galaxy.music.widget;

import android.content.Context;
import android.content.SharedPreferences;

public class WidgetConfigDatabase {

	private static final String PREFS_NAME = "com.demboos.galaxy.music.widget";
	private static final String PREF_LAYOUTKEY_FORMAT = "widget_%d_layout";

	static synchronized void setLayoutKey(Context context, int appWidgetId,
			int layoutId) {
		SharedPreferences.Editor prefs = context.getSharedPreferences(
				PREFS_NAME, 0).edit();
		prefs.putInt(layoutKey(appWidgetId), layoutId);
		prefs.commit();
	}

	static synchronized int getLayoutKey(Context context, int appWidgetId) {
		SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, 0);
		return prefs.getInt(layoutKey(appWidgetId), R.layout.eclair_album_appwidget);
	}

	static synchronized void delLayoutKey(Context context, int appWidgetId) {
		SharedPreferences.Editor prefs = context.getSharedPreferences(
				PREFS_NAME, 0).edit();
		prefs.remove(layoutKey(appWidgetId));
		prefs.commit();
	}

	static String layoutKey(int appWidgetId) {
		String out = String.format(PREF_LAYOUTKEY_FORMAT, appWidgetId);

		return out;
	}

}
